home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
science
/
sm32a.zip
/
SYMBMATH.H05
< prev
next >
Wrap
Text File
|
1993-11-15
|
8KB
|
181 lines
3.1. Data Types
The data types in SymbMath language is the numbers, constants,
variables, functions, equations, arrays, array index, lists, list index,
and strings. All data can be operated. It is not necessary to declare
data to be which type, as SymbMath can recognize it.
3.1.1 Numbers
The types of numbers are integer, rational, real (floating-point),
and complex numbers in the range from -infinity to infinity.
In fact, the range of the input real numbers is
-inf, -(10^307)^(10^307) to -(10^-307)^(10^-307), 0, (10^-307)^(10^-307)
to (10^307)^(10^307), inf.
The range of the output real numbers is the same as input
when the switch numeric:=off, but when the switch numeric:=on, it is
-inf, -1.E307 to -1.E-307, 0, 1.E-307 to 1.E307, inf.
It means that the number larger than 1.e307 is converted
automatically to inf, the absolute values of the number less than
1.e-307 is converted to 0, and the number less than -1e307 is
converted to -inf.
For examples:
-------------------------------------------
Numbers Type
23 integer
2/3 rational
0.23 real
2.3E2 real
2+3*i complex
2.3+i complex
---------------------------------------------
That "a" and "b" are the same means a-b = 0, while that they are
different means a-b <> 0.
For the real numbers, the upper and lower case letters E
and e in exponent are the same, e.g. 1e2 is the same as 1E2.
3.1.2. Constants
The constants are the unchangeable values. There are some
built-in constants. The name of these built-in constants should be
avoided in the user-defined constants.
------------------------------------------------------------------
Built-in Constants Meanings
pi:=3.1415926536 the circular constant.
e:=2.7182818285 the base of the natural logarithms.
i:=sqrt(-1) the imaginary sign of complex numbers.
inf infinity.
-inf negative infinity.
c_inf complex infinity, both real and imaginary parts
of complex numbers are infinity. e.g. inf+inf*i.
constant the integral constant.
discont discontinuity, e.g. 1/0.
(You can evaluate the one-
sided value by x=x0+zero or x0-zero if the
value of expression is discont).
x0-zero to evaluate left-sided value when x approach x0
from negative (-inf) direction, as zero -> 0.
x0+zero to evaluate right-sided value when x approach x0
from positive (+inf) direction, as zero -> 0.
undefined the undefined value, e.g. indeterminate forms:
0/0, inf/inf, 0*inf, 0^0, etc.
--------------------------------------------------------------------
Zero is the positive-directed 0, as the built-in constant. f(x0+zero)
is the right-hand sided function value when x approaches to x0 from the
positive direction, i.e. x = x0+. f(x0-zero) is the left-sided function
value when x approaches to x0 from the negative direction, i.e. x = x0-.
e.g. f(1+zero) is the rigth-hand sided function value when x approaches
to 1 from the positive (+infinity) direction, i.e. x = 1+, f(1-zero) is
the left-hand sided function value when x approaches to 1 from the negative
(-infinity) direction, i.e. x = 1-; exp(1/(0+zero)) gives inf,
exp(1/(0-zero)) gives 0.
The inf, discont and undefined can be computed as if numbers.
Example.
IN: inf+2, discont+2, undefined+2
OUT: inf, discont, undefined
Notice that the discont and undefined constants are
different. If the value of an expression at x=x0 is discont, the
expression only has the one-sided value at x=x0 and this one-sided
value is evaluated by x=x0+zero or x=x0-zero. If the value of an
expression at x=x0 is undefined, the expression may be evaluated by
the function lim().
Example 3.1.1. evaluate exp(1/x) and sin(x)/x at x=0.
IN: f(x_) := exp(1/x)
OUT: f(x_) := exp(1/x)
IN: f(0)
OUT: discont # f(0) is discontinuty, only has one sided value
IN: f(0+zero) # right-sided value
OUT: inf
IN: f(0-zero) # left-sided value
OUT: 0
IN: subs(sin(x)/x, x = 0)
OUT: undefined
IN: lim(sin(x)/x, x = 0) # it is evaluated by lim()
OUT: 1
3.1.3. Variables
The sequence of characters is used as the name of variables.
Variable names can be up to 128 characters long. They must begin with a
letter and use only letters and digits. SymbMath knows upper and lower
case distinctions in variable names, so AB, ab, Ab and aB are the
different variables. They are case sensitive until the switch lowercase is
set to on (i.e. lowercase:=on).
Variables can be used to store the results of calculations.
Once a variable is defined, it can be used in another formula. Having
defined X as above, you could define Y := ASIN(X). You can also redefine a
variable by storing a new value in it. If you do this, you will lose the
original value entirely.
Assign a result to a variable, just put
<var-name> := expression
e.g. a := 2 + 3 # assign value to a
Variables can be used like constants in expressions.
For example:
a := 2 + 3
b := a*4
If an undefined variable is used in an expression, then the
expression returns a symbolic result (which may be stored in another
variable). Pick an undefined variable name, say x, and enter:
y := 3 + x # formula results since x undefined
x := 4 # Now x is defined
y # y returns 7, but its value is
# still the formula 3 + x
x := 7 # revalue x
y # new value for y
Note that in symbolic computation, the variable has not only a
numeric value but also a symbolic value.
Symbolic values for variables are useful mostly for viewing
the definitions of functions and symbolic differentiation and
integration.
Watch out for infinite recursion here. Defining
x := x+3
when x has no initial value, it will not cause an immediate problem,
but any future reference to x will result in an infinite recursion !
A value can be assigned to the variable, by one of three methods:
(1) the assignment :=,
(2) the user-defined function f(),
(3) subs(y, x = x0).
e.g.
y:=x^2
x:=2 # assignment
y
f(2) # if f(x) has been defined, e.g. f(x_):=x^2.
subs(x^2, x = 2) # evaluate x^2 when x = 2.
The variable named last is the built-in as the variable last is
always automatically assigned the value of the last output result.
The usual used independent variable is x.
By default, |x| < inf and all variables are complex, except that
variables in inequalities are real, as usual only real numbers can be
compared. e.g. x is complex in sin(x), but y is real in y > 1.
You can restrict the domain of a variable by assuming the variable
is even, odd, integer, real number, positive or negative (see Chapter 4.2
Simplification and Assumption).
3.1.4 Patterns
Patterns stand for classes of expressions.
_ any expression.
x_ any expression, given the name x.
Patterns should appear on the left-hand side of the assignment only,
not on the right-hand side of the assignment. Patterns are only used in
definition of functions, procedures and rules.
Patterns in SymbMath language are similar with patterns in such
language as MATHEMATICA.